package com.firefly.web.controller.admin.cms;

import com.firefly.web.controller.admin.ConsoleApiRestController;
import com.firefly.dao.dto.cms.ConfigDto;
import com.firefly.dao.vo.cms.ConfigVo;
import com.firefly.service.command.cms.ConfigCommand;
import com.firefly.service.query.cms.ConfigQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @author makejava
 * @since 2022-08-02 08:57:45
 */
@ConsoleApiRestController("/config")
public class ConfigController {
    private final ConfigQuery configQuery;
    private final ConfigCommand configCommand;
    @Autowired
    public ConfigController(ConfigCommand configCommand,ConfigQuery configQuery){
        this.configQuery = configQuery;
        this.configCommand = configCommand;
    }

    @GetMapping("/get")
    public ConfigVo getDetail() {
        return configQuery.getDetail(1);
    }

    @PostMapping("/update")
    public Boolean postDetail(@Validated ConfigDto request) {
        return configCommand.updateById(request);
    }
}

